import express from 'express'
import cors from 'cors'
import morgan from 'morgan'
import routes from './routes'
import { errorHandler } from './middlewares/errorHandler'

const app = express()

// 中间件
app.use(morgan('dev'))
app.use(cors())
app.use(express.json())

// API 路由
app.use('/api', routes)

// 错误处理
app.use(errorHandler)

export default app